clear
%% PROBLEM
%   'EqualMinima','Himmelblau','Sixhump','ModifiedRastrigin','Vincent',
%   'Shubert','Composition','IncreasingMinima','Rastrigin','Schaffer'.
ProblemSet.FuncType = 'EqualMinima';
ProblemSet.dimension = 3;
% ProblemSet.k = [3,3,3];
% ProblemSet.BaseFunc = 3;

[d, x_bound, ObjFunc, OptSet, ~, ~, PopulationSize, MaximalBudget, FileName]...
    = problem_setting(ProblemSet);

epsilon = [0.1,0.01,0.001,0.0001];

%% problem
Problem.Dimension = d; % the dimension of the decision variable
Problem.LowerBound = x_bound(1,:); % the lower bound of the decision variable
Problem.UpperBound = x_bound(2,:); % the upper bound of the decision variable
Problem.ObjFunc = ObjFunc;  % the objective function
%% ALGORITHM
Algorithm.PopulationSize = PopulationSize;  % the population size of the ga
Algorithm.MaxFEs = MaximalBudget;
Algorithm.F = 0.5;  % the crossover probability
Algorithm.CR = 0.7;  % the mutation probability
Algorithm.radius = 0.01;  % the distance parameter
%% OPTIMIZATION
rep = 100;
TotalBudget = zeros(rep,length(epsilon));
OptNoFound = zeros(rep,length(epsilon));
TotalGeneration = zeros(rep,length(epsilon));
Times = zeros(rep,length(epsilon));
%%
for iepsilon = 1:length(epsilon)
	OptSet.epsilon = epsilon(iepsilon);
    for i = 1:rep
        disp(['epsilon: ',num2str(epsilon(iepsilon)),', replication: ',num2str(i),'.'])
        tic
        [~, ~, EvaluationNum, GenerationNum, OptSetRemain]...
            = mommop_test(Problem, Algorithm, OptSet);
        Times(i,iepsilon) = toc;
        disp(['time used: ',num2str(Times(i,iepsilon)),'.'])
        TotalBudget(i,iepsilon) = EvaluationNum;
        OptNoFound(i,iepsilon) = size(OptSetRemain,1);
        TotalGeneration(i,iepsilon) = GenerationNum;
    end
end
%%
save(FileName)
